//
//  PBComfimHomeController.m
//  PBHomeDemo
//
//  Created by Playboy on 2018/1/12.
//  Copyright © 2018年 tmkj. All rights reserved.
//

#import "PBComfimHomeController.h"
#import "WXApi.h"
#import "PBRentDateController.h"

@interface PBComfimHomeController ()
@property (weak, nonatomic) IBOutlet UIImageView *coverImageView;
@property (weak, nonatomic) IBOutlet UILabel *mainLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *bigLabel;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *sexLabel;
@property (weak, nonatomic) IBOutlet UILabel *idCardLabel;
@property (weak, nonatomic) IBOutlet UIButton *sureButton;
@property (strong, nonatomic) IBOutlet UILabel *phoneLabel;



@end

@implementation PBComfimHomeController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self configure];
}
- (void)configure {
    [self configureView];
    [self configureData];
}

- (void)configureView {
    [TMNetwork requestGetWithParam:@{} url:@"/user/identifyCard/get" callback:^(TMBaseReqModel *model) {
        if (model.code == 200) {
            self.nameLabel.text = model.data[@"realName"];
            self.idCardLabel.text = model.data[@"identifyCardNum"];
            if ([model.data[@"sex"] integerValue] == 1) {
                self.sexLabel.text = @"男";
            }else if ([model.data[@"sex"] integerValue] == 2) {
                self.sexLabel.text = @"女";
            }
            self.phoneLabel.text = model.data[@"mobile"];
        }else {
            [self showHint:model.message];
        }
    }];
}
- (void)configureData {
    [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:self.model.cover] placeholderImage:nil];
    self.mainLabel.text = self.model.name;
    self.priceLabel.text = [NSString stringWithFormat:@"%@元/月",self.model.rent];
    self.bigLabel.text = [NSString stringWithFormat:@"%@㎡",self.model.area];
    if (self.isOrder) {
        self.sureButton.hidden = YES;
    }
}


// 确认信息
- (IBAction)sureInfoButtonClikc:(UIButton *)sender {
    PBRentDateController *vc = [[PBRentDateController alloc] init];
    vc.model = self.model;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - super
- (void)resetNavigationBarItems {
    [super resetNavigationBarItems];
    if (self.isOrder) {
        self.title = @"订单详情";
    }else {
        self.title = @"信息确认";
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
